package com.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javabean.User;
import com.mapper.UserMapper;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/users/findAll")
    public String findAll(HttpServletRequest request, @RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "page",defaultValue = "5")int limit){
        PageHelper.startPage(1,5);

        List<User> all=userService.findAll();
        request.setAttribute("all",all);
        PageInfo<User> pageInfo=new PageInfo<>(all);
        request.setAttribute("pageInfo",pageInfo);
        return "users/users-list";
    }
}
